<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Queries\VehicleQuery;
use App\Http\Resources\VehicleResource;

class VehicleController extends Controller
{
    public function index(VehicleQuery $query)
    {
        $rows = $query->where('show', true)->paginate(10);
        return $this->resource(VehicleResource::collection($rows));
    }

    public function show($id, VehicleQuery $query)
    {
        $row = $query->findOrFail($id);
        return $this->resource(new VehicleResource($row));
    }

    public function all(VehicleQuery $query)
    {
        $rows = $query->get();
        return $this->resource(VehicleResource::collection($rows));
    }
}
